<template>
  <el-dropdown @command="handleCommand" trigger="click">
    <span class="el-dropdown-link">
      <ri i="user"></ri>
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="detail" icon="el-icon-s-custom">详细信息</el-dropdown-item>
      <el-dropdown-item command="configuration" icon="el-icon-s-tools">个人设置</el-dropdown-item>
      <el-dropdown-item command="logout" icon="el-icon-switch-button">退出登录</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  methods: {
    handleCommand(command) {
      if (command == 'logout') {
        this.logout()
      }
    },
    logout() {
      this.$store.dispatch('logout')
      this.$router.push('/user/login')
    }
  }
};
</script>

<style lang="stylus" scoped>
span.el-dropdown-link
  border 1px solid #ccc
  border-radius 5px
  text-align center
  cursor pointer
  font-size 2em
  padding 2px

  .icon-button
    margin-right 5px
</style>
